#!/bin/sh
# mvn 自动打包，并cp war包
function war(){
target=$1
source=$2
echo "start ..."
cd $source
pwd
git checkout master
echo  "===切换master分支"
git pull
echo  "===更新最新代码"
mvn clean
echo  "===mvn clean"
mvn install -Pidc -Dmaven.test.skip=true
echo "===mvn install"
if !(test -d $target) then
    mkdir -p $target
    echo "===目录不存在，创建目录$target"
else
    #rm -r $target/*
    echo "===目录存在，清理目录内容"
fi
find ./ -name "*.war" | xargs -t -I {} cp {} $target
echo "=== 复制war包"
echo "end ..."
}

billing_target=~/Downloads/release
payadmin_target=~/Downloads/release

billing_source=/Users/liuyang/release/billing
payadmin_source=/Users/liuyang/release/payadmin

for i in $@; do
    if [ "$i"x = "billing"x ]; then
        war $billing_target $billing_source
    elif [ "$i"x = "payadmin"x ]; then
        war $payadmin_target $payadmin_source
    else
        echo "unknow project..."
    fi
done



